package org.codeart.juc.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FixedThreadPoolDemo {

    public static void main(String[] args) {
        ExecutorService pool = Executors.newFixedThreadPool(3);
        pool.execute(() -> {
            System.out.println("1号任务: " + Thread.currentThread().getName() + "-" + System.currentTimeMillis());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        pool.execute(() -> {
            System.out.println("2号任务: " + Thread.currentThread().getName() + "-" + System.currentTimeMillis());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        pool.execute(() -> {
            System.out.println("3号任务: " + Thread.currentThread().getName() + "-" + System.currentTimeMillis());
        });
        
        // 退出程序
        pool.shutdown();
    }

}
